<template>
	<view class="contain">
		<uni-forms :modelValue="formData">
			<uni-forms-item label="原密码" name="name">
				<uni-easyinput type="text" v-model="formData.password" placeholder="请输入原密码" />
			</uni-forms-item>
			<uni-forms-item label="新密码" name="name">
				<uni-easyinput type="text" v-model="formData.newpassword" placeholder="请输入新密码" />
			</uni-forms-item>
		</uni-forms>
		<button @click="pass">保存</button>
	</view>
</template>

<script>
	import {postpassword} from '@/utils/myinfo/index.js'
	export default {
		data() {
			return {
				formData:{
					oldPassword:"",
					newPassword:""
				}
				
			}
		},
		methods: {
			async pass(){
				const res=await postpassword(this.formData)
				const code=res.data.code
				if(code==500){
					uni.showToast({
						icon:'error',
						title:res.data.msg
					})
				}else{
					uni.showToast({
						icon:'success',
						title:res.data.msg,
						success() {
							uni.navigateTo({
								url:"/pages/login/login"
							})
						}
					})
				}
				
			}
		}
	}
</script>

<style>
	.contain{
		width: 95%;
		margin: 20rpx auto;
	}

</style>
